package com.example.springbootmybatis.exception;

import com.example.springbootmybatis.entity.ResultMap;

import static com.example.springbootmybatis.exception.ResponseEnum.SUCCESS;

public class BaseResultUtils {


    public static ResultMap setResult(Integer code, String msg, Object data) {
        return new ResultMap(code, msg, data);
    }

    public static ResultMap setResult(int code, String msg) {
        return setResult(code, msg, null);
    }

    public static ResultMap success(Object data){
        return setResult(SUCCESS.getReturnCode(),SUCCESS.getReturnMessage(),data);
    }

    public static ResultMap error(ResponseEnum responseEnum) {
        return setResult(responseEnum.getReturnCode(),responseEnum.getReturnMessage());
    }
}